<!-- 级别管理 -->
<template>
  <div class="levelManage">
    <Add ref="add"></Add>
    <ServiceAuth ref="serviceAuth"></ServiceAuth>
    <ZgNewPage
      ref="page"
      title="级别管理"
      :showInlineBtn="false"
      uniqueName="test"
      :pageOpt="pageOpt"
      :dataBtns="dataBtns"
      :conditions="conditions"
      :extraBtns="extraBtns"
      :headers="headers"
      :adminWidth="330"
      :scrollX="1500"
      @search="onSearch"
      @admin="toAdmin"
      @extra="toExtra"
    >
      <template slot="columns">
        <a-table-column v-for="column in headers" :key="column.code" :title="column.label">
          <template slot-scope="text, record">{{ record[column.code] }}</template>
        </a-table-column>
      </template>
    </ZgNewPage>
  </div>
</template>
<script>
export default {
  data() {
    return {
      pageOpt: {
        showPageTitle: true
      },
      dataBtns: [
        {
          key: 'delete',
          type: 'link',
          name: '删除',
          isShow: () => {
            return true
          }
        },
        {
          key: 'moveUp',
          type: 'link',
          name: '上移',
          isShow: () => {
            return true
          }
        },
        {
          key: 'moveDown',
          type: 'link',
          name: '下移',
          isShow: () => {
            return true
          }
        },
        {
          key: 'serviceAuth',
          type: 'link',
          name: '业务权限',
          isShow: () => {
            return true
          }
        }
      ],
      headers: [
        { code: 'levelName', label: '级别名称' },
        {
          code: 'score',
          label: '分数范围(大于等于)'
        }
      ],
      conditions: [
        {
          code: 'levelName',
          label: '级别名称',
          compType: '单行文本',
          defaultVal: '',
          extra: { placeholder: '请输入级别名称' }
        }
      ],
      extraBtns: [{ key: 1, name: '新增级别', icon: 'plus-circle', type: 'primary' }]
    }
  },
  components: {
    Add: () => import('./Add.vue'),
    ServiceAuth: () => import('./ServiceAuth.vue')
  },
  computed: {},
  methods: {
    onSearch() {
      this.$refs.page.endSearch({
        total: 2,
        list: [{}, {}]
      })
    },
    toAdmin(data) {
      const { key, obj } = data
      if (key === 'delete') {
        this.confirm(() => {}, '确定要删除这条数据么')
      } else if (key === 'moveUp') {
      } else if (key === 'moveDown') {
      } else if (key === 'serviceAuth') {
        this.$refs.serviceAuth.open(obj)
      }
    },
    toExtra() {
      this.$refs.add.open('add')
    }
  },
  created() {},
  mounted() {}
}
</script>
<style lang="less" scoped></style>
